import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common'
import { RoleService } from './role.service'
import { CreateRoleDto } from './dto/create-role.dto'
import { UpdateRoleDto } from './dto/update-role.dto'
import { ApiTags } from '@nestjs/swagger'
import { JwtAuthGuard } from 'src/auth/jwt-auth.guard'

@ApiTags('角色')
@UseGuards(JwtAuthGuard)
@Controller('role')
export class RoleController {
  constructor(private readonly roleService: RoleService) { }

  @Post('/create')
  createRole(@Body() createRoleDto: CreateRoleDto) {
    return this.roleService.createRole(createRoleDto)
  }

  @Post('/updateRole')
  update(@Body() updateRoleDto: UpdateRoleDto) {
    return this.roleService.update(updateRoleDto)
  }

  @Get('/getRoleList')
  getRoleList() {
    return this.roleService.getRoleList()
  }

  @Get('/getRoleMenus/:id')
  getRoleMenus(@Param('id') id: string) {
    return this.roleService.getRoleMenus(+id)
  }


  @Get('/deletRole/:id')
  remove(@Param('id') id: string) {
    return this.roleService.removeRole(+id)
  }
}
